<?php
    require_once("curl.php");
    require_once("gadget.php");

    function replaceMessageInGadget($messageFile, $gadgetContent)
    {
        if ($messageFile != "")
        {
            //add dir
            $messageFile = $GLOBALS['langDir'].$messageFile;

            $messages = simplexml_load_string(get($messageFile));

            //replace messages
            foreach ($messages->msg as $message)
            {
                   $gadgetContent = str_replace("__MSG_".$message['name']."__", $message, $gadgetContent);
            }
        }

        return $gadgetContent;
    }

    function replaceMessageInExternalFiles($messageFile)
    {
        if ($messageFile != "")
        {
            //add dir
            $messageFile = $GLOBALS['langDir'].$messageFile;

            $messages = simplexml_load_string(get($messageFile));

            //replace messages
            foreach ($messages->msg as $message)
            {

                    $GLOBALS['gadgetHtml'] = str_replace("__MSG_".$message['name']."__", $message, $GLOBALS['gadgetHtml']);
                    $GLOBALS['gadgetCss'] = str_replace("__MSG_".$message['name']."__", $message, $GLOBALS['gadgetCss']);
                    $GLOBALS['gadgetJs'] = str_replace("__MSG_".$message['name']."__", $message, $GLOBALS['gadgetJs']);

            }
        }
    }
?>